import React from 'react'
import {
  Pressable, PressableProps, StyleProp, View, ViewStyle,
} from 'react-native'

const Button: React.FC<PressableProps & React.RefAttributes<View> & { opacity?: number }> = (props) => {
  const {
    onPress, children, style, opacity = 0.2, ...rest
  } = props
  return (
    <Pressable
      onPress={onPress}
      {...rest}
      style={({ pressed }) => [style, pressed && { opacity }] as StyleProp<ViewStyle>}
    >
      {children}
    </Pressable>
  )
}

export default Button
